<template>
  <div style="height: 523px; overflow: hidden; background: white; border:1px solid white ; border-radius: 12px;margin-top:10px ">
   <!-- <el-row>
      <el-col :span="24">

        <el-breadcrumb style="width:500px; font-size: 13px; margin-top: 10px; margin-left: 10px; "
          separator-class="el-icon-arrow-right">
          <el-breadcrumb-item>库存管理</el-breadcrumb-item>
          <el-breadcrumb-item> 入库管理</el-breadcrumb-item>
          <el-breadcrumb-item style="color: red;">入库登记复核</el-breadcrumb-item>

        </el-breadcrumb>
      </el-col>
    </el-row> -->
    <div style="background-color: white; height: 20px; text-align: left; padding: 10px; margin-top: 15px;">
    <h4>  当前等待复核的入库登记总数：0例

</h4>
    </div>
    <div style="background-color: #E9EEF3; height: 400px; margin: 10px; padding: 4px; border-radius: 7px;">
      <template>
        <el-table :data="tableData" style="width: 100% ">
          <el-table-column prop="repjingid" label="入库单编号" width="320">
          </el-table-column>
          <el-table-column prop="reason" label="入库理由" width="180">
          </el-table-column>
          <el-table-column prop="timekc" label="登记时间" width="100">
          </el-table-column>
          <el-table-column prop="rukuzonshuliang" label="总件数" width="100">
          </el-table-column>
          <el-table-column prop="rukujiagezonjia" label="总金额(元)" width="100">
          </el-table-column>

          <el-table-column label="复核" width="100">
           <template slot-scope="scope">
                <el-button size="mini" @click.native.prevent="fh(scope.row.rukucpid)" round>登记</el-button>
           </template>
          </el-table-column>
        </el-table>
      </template>
      <div class="block" style="position: absolute; bottom: 45px; margin-left:250px ;">
        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="14"
          :page-sizes="[100, 200, 300, 400]" :page-size="100" layout="total, sizes, prev, pager, next, jumper"
          :total="400">
        </el-pagination>
      </div>
    </div>

<el-dialog style="position: absolute; top: -78px;" title="入库登记复核6g" :visible.sync="dialogVisible" width="90%"
				  :before-close="handleClose">
				  <el-table :data="tableDataa" size="mini">
				    <el-table-column property="cpbh" label="产品编号" width="180"></el-table-column>
						<el-table-column property="cpmc" label="产品名称" width="190"></el-table-column>
				    <el-table-column property="reason" label="库房名称" width="190"></el-table-column>
						<el-table-column property="pronameClass" label="存储地址名称" width="160"></el-table-column>
				    <el-table-column property="rukuchuliang" label="应入库件数" width="160"></el-table-column>
				    <el-table-column property="yiwcrukushukliang" label="已入库件数" width="160"></el-table-column>
						<el-table-column label="本次入库数量" width="200">
									  <template slot-scope="scope">
            <input type="text"  v-model="scope.row.yiruchushuliang" id="inp" style=" margin-top: 20px;"/>
										</template>
						</el-table-column>

				  </el-table>
				  <div class="block" style="margin-top: 14px;">
				    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
				      :current-page="currentPage4" :page-sizes="[100, 200, 300, 400]" :page-size="100"
				      layout="total, sizes, prev, pager, next, jumper" :total="400">
				    </el-pagination>
				  </div>
				  <span slot="footer" class="dialog-footer">
				    <el-button @click="dialogVisible = false">取 消</el-button>
				    <el-button type="primary" @click="rukuupd">确 定</el-button>
				  </span>
				</el-dialog>


  </div>
</template>

<script>
  export default {
    name: 'repoutsh',
    data() {
      return {
        table: false,
        dialog: false,
        loading: false,
        tableData: [],
				tableDataa: [],
				tableDataaa: [],
        dialogTableVisible: false,
        dialogFormVisible: false,
				dialogVisible:false,
        form: {
          name: '',
          region: '',
          date1: '',
          date2: '',
          delivery: false,
          type: [],
          resource: '',
          desc: ''
        },
      formLabelWidth: '80px',
      timer: null
      }
    },
		mounted(){
			this.$http.post("seldddjfhRepadmin")
				.then((res) => {
						if(res.data){
							 this.tableData=res.data;
																 	this.tableData.forEach(item=>{

																 	if(item.cpleixing==1){

																 		item.cpleixing="商品";

																 	}else if(item.cpleixing==2){

																 			item.cpleixing="物料";

																 	}else if(item.cpleixing==3){

																 			item.cpleixing="委托部件";

																 	}else if(item.cpleixing==4){
																 		item.cpleixing="外购商品";

																 		}else if(item.cpleixing==5){
																 		item.cpleixing="委托产品";

																 		}else if(item.cpleixing==6){
																 		item.cpleixing="服务型产品";

																 		}
																		})
						}
					})
					.catch((err) => { //请求失败
				console.log(err);
			});
		},
    methods: {
			rukuupd(){
				this.tableDataa.forEach((item)=>{
					  var demo = new URLSearchParams()
						demo.append("yirukunum","0")
						demo.append("yiwcrukunum",item.yiruchushuliang)
						demo.append("qimunum",item.yiruchushuliang)
						demo.append("rep_jingId",item.repjingid)
					  this.$http.post("upddddjxgshwcrkslReo_jing",demo)
						.then((res)=>{
							this.tableDataaa=res.data;
							this.tableDataa.forEach((itemm)=>{
							if(itemm.yiruchushuliang==itemm.rukuchuliang){
									 var demo1=new URLSearchParams()
									demo1.append("ReviewSigng","已复核")
									demo1.append("rep_jingId",itemm.repjingid)
									this.$http.post("updddfh",demo1)
									.then((res)=>{
																	 this.tableDataa=res.data;
																	 this.dialogVisible=false;

																			 })
									.catch((err)=>{ //请求失败
										console.log(err);
										})

							}else{
									alert(itemm.rukuchuliang+"|***|"+itemm.kucunshuliang)
									 var demo1=new URLSearchParams()
									demo1.append("ReviewSigng","未复核")
									demo1.append("rep_jingId",itemm.repjingid)
									this.$http.post("updddfh",demo1)
									.then((res)=>{

																	 this.tableDataa=res.data;
																			  this.dialogVisible=false;
																			 })
									.catch((err)=>{ //请求失败
										console.log(err);
										})
							}
							})
						})
						.catch((err)=>{ //请求失败
							console.log(err);
						})
				})
			},
			fh(row){
				var demo=new URLSearchParams()
				demo.append("rukucpid",row)
				this.$http.post("seliddddjfhRepadmin",demo)
				.then((res) => {
							if(res.data){
								 this.tableDataa=res.data;
																	 	this.tableData.forEach(item=>{

																	 	if(item.cpleixing==1){

																	 		item.cpleixing="商品";

																	 	}else if(item.cpleixing==2){

																	 			item.cpleixing="物料";

																	 	}else if(item.cpleixing==3){

																	 			item.cpleixing="委托部件";

																	 	}else if(item.cpleixing==4){
																	 		item.cpleixing="外购商品";

																	 		}else if(item.cpleixing==5){
																	 		item.cpleixing="委托产品";

																	 		}else if(item.cpleixing==6){
																	 		item.cpleixing="服务型产品";

																	 		}
																			})
							}
						})
						.catch((err) => { //请求失败
					console.log(err);
				});
				this.dialogVisible = true;
			},
      tableRowClassName({
        row,
        rowIndex
      }) {
        if (rowIndex === 1) {
          return 'warning-row';
        } else if (rowIndex === 3) {
          return 'success-row';
        }
        return '';
      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
      },
      handleClose(done) {
        if (this.loading) {
          return;
        }
        this.$confirm('确定要提交表单吗？')
          .then(_ => {
            this.loading = true;
            this.timer = setTimeout(() => {
              done();
              // 动画关闭需要一定的时间
              setTimeout(() => {
                this.loading = false;
              }, 400);
            }, 2000);
          })
          .catch(_ => {});
      },
      cancelForm() {
        this.loading = false;
        this.dialog = false;
        clearTimeout(this.timer);

      }
    }
  }
</script>

<style scoped="scoped">
  * {
    padding: 0px;
    margin: 0px;
  }

  .el-breadcrumb__inner {
    color: black;

  }

  .el-input__inner {

    height: 25px;

  }

  .el-input__prefix,
  .el-input__suffix {
    position: absolute;
    top: 7px;
    -webkit-transition: all .3s;
    height: 100%;
    color: #C0C4CC;
    text-align: center;
  }

  .el-table td {
    padding: 10px 0;
  }
</style>
